<?php
$public = [];
$v1 = [
    //============================== 公共接口开始 ==============================
    //首页
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/home', 'pluralize' => false,
        'extraPatterns' => [
            'POST,DELETE upload' => 'upload',
            'POST upload-for-wang' => 'upload-for-wang',
            'POST up-token' => 'up-token',

            'GET card-data' => 'card-data',   //获得首页头部统计
        ]
    ],

    //管理员管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/admin', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',               #获取管理员列表
            'POST,GET info' => 'info',          #获取、修改管理员信息
            'POST status' => 'status',          #获取管理员状态
            'GET login-log' => 'login-log',        #获取登录日志
            'GET admin-info' => 'admin-info',   #获取管理员基础信息--登录之后获取
            'GET,POST,DELETE mfa' => 'mfa',   #获取管理员基础信息--登录之后获取

            //管理员角色
            'GET role-map' => 'role-map',
            'GET role-list' => 'role-list',
            'GET,POST role-info' => 'role-info',
            'GET role-tree' => 'role-tree',
            'POST role-status' => 'role-status'
        ]
    ],

    //管理员登录相关
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/login', 'pluralize' => false,
        'extraPatterns' => [
            'GET captcha' => 'captcha',     //验证码
            'POST in' => 'in',     //登入
            'POST out' => 'out',     //登出
        ]
    ],
    // 充值管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/recharge', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',     // 充值
            'GET type-map' => 'type-map',     // 充值
            'GET status-map' => 'status-map',     // 充值
            'GET setting-list' => 'setting-list',
            'GET,POST setting-add-edit' => 'setting-add-edit',
            'POST setting-switch-status' => 'setting-switch-status',
        ]
    ],

    //访问控制相关 API
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/access', 'pluralize' => false,
        'extraPatterns' => [
            'GET menu' => 'menu',                   #根据权限获取菜单列表

            'GET module' => 'module',               #获取模块列表
            'GET module-map' => 'module-map',       #获取模块map
            'GET,POST module-info' => 'module-info',       #获取、修改 模块信息
            'POST module-order' => 'module-order',       #排序
            'POST module-status' => 'module-status',       #排序

            'GET,POST module-action-add-edit' => 'module-action-add-edit',       #获取action 修改action
            'GET action-request-map' => 'action-request-map',       #获取action requestMap
        ]
    ],

    //common API
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/common', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',          #获取列表信息
            'POST info' => 'info',          #修改单个信息
        ]
    ],

    //操作日志
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/system', 'pluralize' => false,
        'extraPatterns' => [
            'GET operate-log' => 'operate-log',     //操作日志
        ]
    ],

    //请求统计
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/api', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',     //请求统计
        ]
    ],

    //图片设置
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/images', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',               #获取列表
            'GET,POST add-edit' => 'add-edit',          #获取修改信息
            'POST order' => 'order',               #排序
            'POST switch-status' => 'switch-status',          #启用 禁用
            'GET jump-type-map' => 'jump-type-map',          #启用

            'GET position' => 'position',               #获取列表
        ]
    ],

    //版本管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/versions', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
        ]
    ],
    //============================== 公共接口结束 ==============================

    //用户相关
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/user', 'pluralize' => false,
        'extraPatterns' => [
            //用户列表
            'GET list' => 'list',                                   //用户列表
            'GET,POST add-edit' => 'add-edit',                      //用户信息编辑和获取
            'POST multiple-add' => 'multiple-add',                      //用户信息编辑和获取
            'POST field' => 'field',                //用户状态MAP
            'GET user-register' => 'user-register',                 //用户一周注册柱状图
            'GET user-map' => 'user-map',                           //用户map

            //用户登录日志
            'GET login-log' => 'login-log',   //用户登录日志列表
            'GET login-statistic' => 'login-statistic',   //用户登录日志列表
            'POST clean' => 'clean',    //清理用户

            //实名审核
            'GET real-list' => 'real-list',                 //列表
            'POST real-examine' => 'real-examine',           //实名审核
            'POST change-active' => 'change-active',           //活跃度变更

            //商家审核
            'GET business-list' => 'business-list',                 //列表
            'POST business-examine' => 'business-examine',           //实名审核

            //用户异常处理
            'GET unusual-list' => 'unusual-list',               //列表
            'GET unusual-status-map' => 'unusual-status-map',   //状态
            'GET unusual-type-map' => 'unusual-type-map',               //异常类型
            'GET,POST unusual-add-edit' => 'unusual-add-edit',  //编辑和获取
            'POST unusual' => 'unusual',               //封禁
        ]
    ],

    //用户级别
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/user-level', 'pluralize' => false,
        'extraPatterns' => [
            //用户级别
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
            'POST set-field' => 'set-field',
            'GET map' => 'map',

            //用户级别订单
            'GET order-list' => 'order-list',
        ]
    ],

    //金币设置
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/coin', 'pluralize' => false,
        'extraPatterns' => [
            //金币充值设置
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
            'POST set-field' => 'set-field',
            'GET map' => 'map',

            //金币充值订单
            'GET order-list' => 'order-list',
            'GET del-order' => 'del-order',
        ]
    ],


    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/receipt', 'pluralize' => false,
        'extraPatterns' => [

            'GET bank-list' => 'bank-list',
            'GET,POST bank' => 'bank',
        ]
    ],

    // 提现
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/withdraw', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',
            'POST success' => 'success',
            'POST reject' => 'reject',
            'GET status-map' => 'status-map',
            'GET money' => 'money',
        ]
    ],


    // 认证
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/kyc', 'pluralize' => false,
        'extraPatterns' => [
            'POST cancel' => 'cancel',
            'POST do' => 'do',
        ]
    ],




    //商城管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/shop', 'pluralize' => false,
        'extraPatterns' => [
            # 分类
            'GET category-list' => 'category-list',
            'GET,POST category-add-edit' => 'category-add-edit',
            'DELETE category-delete' => 'category-delete',
            'POST category-switch-status' => 'category-switch-status',
            'POST category-order' => 'category-order',
            'GET category-tree' => 'category-tree',
            'GET category-special-map' => 'category-special-map',
            'GET category-map' => 'category-map',

            # 商品
            'GET list' => 'list',
            'GET all-list' => 'all-list',
            'GET,POST add-edit' => 'add-edit',
            'GET map' => 'map',
            'DELETE delete' => 'delete',
            'POST switch-status' => 'switch-status',
            'POST examine' => 'examine',                            #审核

            # 商品详情
            'GET detail-multi' => 'detail-multi',
            'POST detail-multi' => 'detail-multi',

            //评论列表
            'GET comment-list' => 'comment-list',
            'GET comment-del' => 'comment-del',
            'GET comment-audit' => 'comment-audit',
            'POST comment-examine' => 'comment-examine',

            # 商城订单
            //GOODS 订单
            'GET goods-order-list' => 'goods-order-list',
            'GET goods-order-status-map' => 'goods-order-status-map',
            'POST goods-order-deliver' => 'goods-order-deliver',
            'GET goods-order-info' => 'goods-order-info',
            'GET goods-order-detail-info' => 'goods-order-detail-info',
            'DELETE goods-order-delete' => 'goods-order-delete',
            'GET order-return' => 'order-return',             //获取退款信息
            'POST edit-return' => 'edit-return',             //同意或驳回申请
            'POST order-cancel' => 'order-cancel',             //取消订单
        ]
    ],

    //商城快递
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/express', 'pluralize' => false,
        'extraPatterns' => [
            'GET map' => 'map',
            'GET type-map' => 'type-map',
        ]
    ],




    //============================== IM管理 ==============================
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/im', 'pluralize' => false,
        'extraPatterns' => [

            # 好友列表
            'GET friend-list' => 'friend-list',

            # 群列表
            'GET group-list' => 'group-list',
            'DELETE group-cancel' => 'group-cancel',
            'POST group-switch-status' => 'group-switch-status',

            # 群成员列表
            'GET group-user-list' => 'group-user-list',

            # 朋友圈
            'GET circle-list' => 'circle-list',
            'GET circle-del' => 'circle-del',
            'POST circle-top' => 'circle-top',

            # 收入明细
            'GET detailed-list' => 'detailed-list',
            'GET detailed-type-map' => 'detailed-type-map',
        ]
    ],

    // 红包管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/red-packet', 'pluralize' => false,
        'extraPatterns' => [
            'GET red-list' => 'red-list',
            'GET red-log-list' => 'red-log-list',
        ]
    ],

    // 转账管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/transfer', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',
        ]
    ],


    //============================== 消息管理 ==============================
    # 文章管理
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/article', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
            'POST switch-status' => 'switch-status',
            'DELETE delete' => 'delete',
        ]
    ],

    //系统消息
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/message', 'pluralize' => false,
        'extraPatterns' => [
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
            'POST send' => 'send',
        ]
    ],



    //============================== 财务管理 ==============================
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/user-fund', 'pluralize' => false,
        'extraPatterns' => [
            //流水明细
            'GET money-change-list' => 'money-change-list',
            'GET money-change-type-map' => 'money-change-type-map',
            'GET tag' => 'tag',
            'GET full' => 'full',
        ]
    ],


    //============================== 圈子管理 ==============================
    # 圈子列表
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/circle', 'pluralize' => false,
        'extraPatterns' => [
            'GET circle-list' => 'circle-list',
            'GET circle-del' => 'circle-del',
            'POST examine' => 'examine',
            'GET audit' => 'audit',
            'GET comment-list' => 'comment-list',
            'GET comment-del' => 'comment-del',
            'GET comment-audit' => 'comment-audit',
            'POST comment-examine' => 'comment-examine',
        ]
    ],

    // 反馈信息
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/feedback', 'pluralize' => false,
        'extraPatterns' => [
            // 反馈分类
            'GET type' => 'type',                   #获取反馈分类信息
            'GET,POST type-info' => 'type-info',    #获取反馈分类和添加修改
            'POST type-field' => 'type-field',      #获取反馈分类切换状态或者删除

            // 反馈信息
            'GET list' => 'list',                   #获取反馈信息列表
            'GET,POST info' => 'info',              #获取反馈信息
            'POST reply' => 'reply',                #回复
            'DELETE del' => 'del',                    #删除
            'GET audit' => 'audit',                    #待审核
        ]
    ],

    //============================== 举报管理 ==============================
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/report', 'pluralize' => false,
        'extraPatterns' => [
            // 反馈分类
            'GET category-list' => 'category-list',
            'GET,POST category-add-edit' => 'category-add-edit',
            'POST category-field' => 'category-field',

            // 举报信息
            'GET list' => 'list',
            'GET,POST info' => 'info',
            'POST del' => 'del',
        ]
    ],

    //============================== 礼物管理 ==============================
    [
        'class' => 'yii\rest\UrlRule', 'controller' => 'v1/gift', 'pluralize' => false,
        'extraPatterns' => [
            // 礼物分类
            'GET category-list' => 'category-list',
            'GET,POST category-add-edit' => 'category-add-edit',
            'POST category-set-field' => 'category-set-field',
            'GET category-map' => 'category-map',

            // 礼物列白哦
            'GET list' => 'list',
            'GET,POST add-edit' => 'add-edit',
            'POST set-field' => 'set-field',
        ]
    ],
];
$v2 = [];
function addOptions($rules = [])
{
    foreach ($rules as $k => $v) {
        if (!array_key_exists('OPTIONS <action>', $v['extraPatterns'])) {
            $rules[$k]['extraPatterns']['OPTIONS <action>'] = 'options';
        }

    }
    return $rules;
}

$rules = array_merge(addOptions($v1), addOptions($v2), $public);


return [
    "rules" => $rules
];
